#include "ClassWithStrings.h"

QString COLUMN_NAME_ATTRIBUTEUNSIGNEDCHAR = "attributeUnsignedChar";
QString COLUMN_NAME_ATTRIBUTEQSTRING = "attributeQString";
QString COLUMN_NAME_ATTRIBUTESTRING = "attributeString";
QString COLUMN_NAME_ATTRIBUTECHAR = "attributeChar";
QString COLUMN_NAME_ATTRIBUTEUCHAR = "attributeUChar";

QString COLUMN_TYPE_ATTRIBUTEUNSIGNEDCHAR = "unsigned char";
QString COLUMN_TYPE_ATTRIBUTEQSTRING = "QString";
QString COLUMN_TYPE_ATTRIBUTESTRING = "string";
QString COLUMN_TYPE_ATTRIBUTECHAR = "char";
QString COLUMN_TYPE_ATTRIBUTEUCHAR = "uchar";

ClassWithStringsBear::ClassWithStringsBear()
{
    m_object = new BBObject;
    m_object->setName( "ClassWithStrings" );
    m_object->setAttributeType( COLUMN_NAME_ATTRIBUTEUNSIGNEDCHAR, COLUMN_TYPE_ATTRIBUTEUNSIGNEDCHAR );
    m_object->setAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTEUNSIGNEDCHAR, NULL );
    m_object->setAttributeType( COLUMN_NAME_ATTRIBUTEQSTRING, COLUMN_TYPE_ATTRIBUTEQSTRING );
    m_object->setAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTEQSTRING, NULL );
    m_object->setAttributeType( COLUMN_NAME_ATTRIBUTESTRING, COLUMN_TYPE_ATTRIBUTESTRING );
    m_object->setAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTESTRING, NULL );
    m_object->setAttributeType( COLUMN_NAME_ATTRIBUTECHAR, COLUMN_TYPE_ATTRIBUTECHAR );
    m_object->setAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTECHAR, NULL );
    m_object->setAttributeType( COLUMN_NAME_ATTRIBUTEUCHAR, COLUMN_TYPE_ATTRIBUTEUCHAR );
    m_object->setAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTEUCHAR, NULL );
    addObject( m_object );
}

unsigned char ClassWithStringsBear::getAttributeUnsignedChar()
{
    QString character = m_object->getAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTEUNSIGNEDCHAR ).toString();
    return character[0].toAscii();
}

void ClassWithStringsBear::setAttributeUnsignedChar( unsigned char value )
{
    m_object->setAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTEUNSIGNEDCHAR, QString( value ) );
}

QString ClassWithStringsBear::getAttributeQString()
{
    return m_object->getAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTEQSTRING ).toString();
}

void ClassWithStringsBear::setAttributeQString( QString value )
{
    m_object->setAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTEQSTRING, value );
}

std::string ClassWithStringsBear::getAttributeString()
{
    return m_object->getAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTESTRING ).toString().toStdString();
}

void ClassWithStringsBear::setAttributeString( std::string value )
{
    m_object->setAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTESTRING, QString::fromStdString( value ) );
}

char ClassWithStringsBear::getAttributeChar()
{
    QString character = m_object->getAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTECHAR ).toString();
    return character[0].toAscii();
}

void ClassWithStringsBear::setAttributeChar( char value )
{
    m_object->setAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTECHAR, QString( value ) );
}

uchar ClassWithStringsBear::getAttributeUChar()
{
    QString character = m_object->getAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTEUCHAR ).toString();
    return character[0].toAscii();
}

void ClassWithStringsBear::setAttributeUChar( uchar value )
{
    m_object->setAttributePrimitiveValue( COLUMN_NAME_ATTRIBUTEUCHAR, QString( value ) );
}

